<?php
/**
 * 工具包
 *
 * @author river_he@eueang.com
 */
final class Gospel_Utility {
/**
	 * 时间戳
	 * 
	 * @var int
	 */
	private static $_timestamp = 0;
	
	/**
	 * 获取时间戳
	 * 
	 * @return int
	 */
	public static function getTimeStamp(){
		if(self::$_timestamp == 0){
			self::$_timestamp = time();
		}
		return self::$_timestamp;
	}
	
	/**
	 * 获取微时间
	 * 
	 * @return float
	 */
	public static function getMicroTime(){
		list($usec, $sec) = explode(' ',microtime());
		return ((float)$usec + (float)$sec); 
	}
	
	/**
	 * 通过经纬度获取地址
	 * 
	 * @param float $lat
	 * @param float $lng
	 * @return String
	 */
	public static function getAddressByLan($lat, $lng){
		$api = 'http://ditu.google.cn/maps/geo?q='.$lat.','.$lng.'&output=json';
		$client = new Hicd_Http_Curl();
		$client->setUrl($api);
		$response = $client->get();
		$return = $response->jsonDecode();
		print_r($return);
	}
	
	/**
	 * 通过地址获取经纬度
	 * 
	 * @param String $address
	 * @return array
	 */
	public static function getLanByAddress($address){
		$api = 'http://ditu.google.cn/maps/geo';
		$api .= '?q='.urlencode($address);
		$api .= '&output=json&oe=utf8&sensor=false';
		$api .= '&key=ABQIAAAAYzHw6g0Pp1KIP87dt7M2dhSID2V4O09l3avVt76v7izRJpFFEBS2st7ySiYTzuEnhhYRoMb1w1Hk5Q';
		//echo $api;
		
		$client = new Hicd_Http_Curl();
		$client->setProxy('127.0.0.1:8580');
		$client->setUrl($api);
		$response = $client->get();
		$return = $response->jsonDecode();
		return $return;
	}
}
//end